/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pk1;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.Timer;

/**
 *
 * @author nghiapt
 */
public class GameFrameGUI extends JPanel implements ActionListener{
    Timer timer;
    GameFrameAgent a;
    
    public GameFrameGUI(GameFrameAgent a){
        this.a = a;
        JFrame frame = new JFrame("Cleaner Agent Frame");
        frame.setSize(800 , 800);
        frame.setResizable(false);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(this);
        frame.setVisible(true);
        setFocusable(true);
        timer = new Timer(10, this);
    }
    
    @Override
    public void paint(Graphics g){
        super.paint(g);
        Graphics2D g2d = (Graphics2D)g;
        g2d.drawString("nghiapt", 100, 100);        
        setBackGround(g2d);
        
    }   

    @Override
    public void actionPerformed(ActionEvent e) {
        repaint();
    }
    
    private void setBackGround(Graphics2D g2d){
        ImageIcon ic = new ImageIcon("D:/nghiapt/AgentProj/Agent/src/pictures/floor.jpg");
        Image i = ic.getImage();
        g2d.drawImage(i, 0, 0, null);
    }
}
